home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / PaperCut Quota / pc-setup.exe / {app} / WebAdmin / OtherCharges.asp < prev    next >
Text File  |  2004-12-06  |  6KB  |  196 lines

  1. <%@ Language=VBScript %>
  2. <%' (c) Copyright 1999-2004 PaperCut Software Pty. Ltd. %>
  3. <!-- #INCLUDE FILE="includes/PCCommon.inc" -->
  4. <!-- #INCLUDE FILE="includes/header.inc" -->
  5. <%
  6.  
  7.  
  8. Dim objPCWebUsers
  9. Set objPCWebUsers = Server.CreateObject("PCWebAdmin.PCWebUsers")
  10. If objPCWebUsers.Error Then
  11.     WriteErrorMessage objPCWebUsers.ErrorDescription
  12. End If
  13.  
  14.  
  15. Function GetChargeError(intError)
  16.     Dim s
  17.  
  18.     If intError = 0 Then
  19.         ' No error
  20.         s = ""
  21.     ElseIf intError = 3 Then
  22.         s = GetText("ErrorTransInvAmount")
  23.     ElseIf intError = 4 Then
  24.         s = GetText("ErrorUnexpectedError")
  25.         s = s & " - " & objPCWebUsers.ErrorDescription
  26.     End If
  27.  
  28.     GetChargeError = s
  29. End Function
  30.  
  31. Dim blnIsValidUser
  32. Dim strChargeUser
  33. Dim strCreditText
  34. Dim strComment
  35. Dim strCharge
  36. Dim intRow
  37. strChargeUser = LCase(Trim(Request("txtChargeUser")))
  38. strComment = Trim(Request("txtAdditionalComment"))
  39. strCharge = Trim(Request("cboCharge"))
  40.  
  41. Dim curAmount
  42. If (IsNumeric(Trim(Request("txtAmount")))) then
  43.     curAmount = CCur(Trim(Request("txtAmount")))
  44. End If
  45.  
  46.  
  47.  
  48. If strChargeUser <> "" Then
  49.     objPCWebUsers.SeekUser(strChargeUser)
  50.     If (UCase(objPCWebUsers.UserName) = UCase(strChargeUser)) then
  51.         blnIsValidUser = True
  52.         strCreditText = objPCWebUsers.CreditText
  53.     End If
  54. End If
  55.  
  56.  
  57. If Request("blnSubmitted") <> "" Then
  58.     Dim strFullComment
  59.  
  60.     If strCharge = "ChargeTypeOther" Then
  61.         strFullComment = GetText("ChargeTypeOther")
  62.     Else
  63.         strFullComment = strCharge
  64.     End If
  65.  
  66.     If strComment <> "" Then
  67.         strFullComment = strFullComment & " - " & strComment
  68.     End If
  69.  
  70.     objPCWebUsers.SeekUser(strChargeUser)
  71.     If (UCase(objPCWebUsers.UserName) <> UCase(strChargeUser)) then
  72.         ' No match.
  73.         WriteErrorMessage GetTextReplace("ErrorCantFindUser", Array(strChargeUser))
  74.     Else
  75.         ' Charge
  76.         If objPCWebUsers.ChargeUser(curAmount, strFullComment) Then
  77.             RedirectWithMessage "UserList.asp?strUsername=" & Server.URLEncode(strChargeUser), GetText("ChargeApplied")
  78.         Else
  79.             WriteErrorMessage GetText("UnableToCharge") & " " & GetChargeError(objPCWebUsers.ProcessErrorNo)
  80.         End If
  81.     End If
  82. End If
  83. %>
  84.     <h1><%=GetText("OtherCharges")%></h1>
  85. <%
  86.     ' Find the details of the user
  87.  
  88. WriteUserAdminLinks strChargeUser
  89. %>
  90.  
  91.  
  92. <FORM ACTION="OtherCharges.asp" METHOD="GET" id="chargesForm" name="chargesForm">
  93. <INPUT type="hidden" name="blnSubmitted" value="T">
  94.  
  95. <TABLE class="webAdmin" width="550">
  96. <% If blnIsValidUser Then %>
  97. <TR class="<%=RowClassHelper(intRow)%>">
  98.     <TH width="45%"><%=GetText("UserToCharge")%>:</TH>
  99.     <TD>
  100.         <%=Server.HTMLEncode(strChargeUser)%>
  101.         <INPUT type="hidden" name="txtChargeUser" value="<%=Server.HTMLEncode(strChargeUser)%>">
  102.         <BR><a class="mouse" href="OtherCharges.asp">(<%=GetText("ChargeDiffUser")%>)</a>
  103.    </TD>
  104. </TR>
  105. <% intRow = intRow + 1 %>
  106. <TR class="oddRow">
  107.     <TH><%=GetText("AvailableCredit")%>:</TH>
  108.     <TD>
  109.         <%=Server.HTMLEncode(strCreditText)%>
  110.    </TD>
  111. </TR>
  112. <% Else %>
  113. <TR class="<%=RowClassHelper(intRow)%>">
  114.     <TH width="45%"><%=GetText("UserToCharge")%>:</TH>
  115.     <TD>
  116.         <INPUT type="text" size="20" name="txtChargeUser" value="<%=Server.HTMLEncode(strChargeUser)%>">
  117.    </TD>
  118. </TR>
  119. <%
  120. End If
  121. intRow = intRow + 1
  122. %>
  123.  
  124.  
  125. <TR class="<%=RowClassHelper(intRow)%>">
  126.     <TH><%=GetText("Amount")%>:</TH>
  127.     <TD>
  128.         <INPUT type="text" size="10" name="txtAmount" value="<%= Server.HTMLEncode(FormatCredit(0)) %>">
  129.    </TD>
  130. </TR>
  131. <% intRow = intRow + 1 %>
  132. <TR class="<%=RowClassHelper(intRow)%>">
  133.     <TH><%=GetText("ChargeType")%>:</TH>
  134.     <TD>
  135.         <SELECT name="cboCharge">
  136.             <%
  137.                 If strCharge = "ChargeTypeOther" Then
  138.                     Response.Write "<OPTION value=""ChargeTypeOther"" SELECTED>" & GetText("ChargeTypeOther") & "</OPTION>" & vbcrlf
  139.                 Else
  140.                     Response.Write "<OPTION value=""ChargeTypeOther"">" & GetText("ChargeTypeOther") & "</OPTION>" & vbcrlf
  141.                 End If
  142.  
  143.                 Dim i
  144.                 Dim strChargeTypeKey, strChargeTypeText
  145.                 If IsArray(garrChargeTypes) Then
  146.                     For i = LBound(garrChargeTypes) to UBound(garrChargeTypes)
  147.                         If strCharge = garrChargeTypes(i) Then
  148.                             Response.Write vbTab & "<OPTION SELECTED>" & Server.HTMLEncode(garrChargeTypes(i)) & "</OPTION>" & vbCRLF
  149.                         Else
  150.                             Response.Write vbTab & "<OPTION>" & Server.HTMLEncode(garrChargeTypes(i)) & "</OPTION>" & vbCRLF
  151.                         End If
  152.                     Next
  153.                 Else
  154.                     i = 0
  155.                     strChargeTypeKey = "OtherChargeType" & CStr(i)
  156.                     Do While HasText(strChargeTypeKey)
  157.                         strChargeTypeText = GetTextNoEncode(strChargeTypeKey)
  158.                         If strCharge = strChargeTypeText Then
  159.                             Response.Write vbTab & "<OPTION SELECTED>" & Server.HTMLEncode(strChargeTypeText) & "</OPTION>" & vbCRLF
  160.                         Else
  161.                             Response.Write vbTab & "<OPTION>" & Server.HTMLEncode(strChargeTypeText) & "</OPTION>" & vbCRLF
  162.                         End If
  163.                         i = i + 1
  164.                         strChargeTypeKey = "OtherChargeType" & CStr(i)
  165.                     Loop
  166.                 End If
  167.  
  168.             %>
  169.         </SELECT>
  170.    </TD>
  171. </TR>
  172. <% intRow = intRow + 1 %>
  173. <TR class="<%=RowClassHelper(intRow)%>">
  174.     <TH><%=GetText("AdditionalComment")%>:</TH>
  175.     <TD>
  176.         <INPUT type="text" size="50" name="txtAdditionalComment" maxlength="255" value="<%=Server.HTMLEncode(strComment)%>">
  177.    </TD>
  178. </TR>
  179. <% intRow = intRow + 1 %>
  180.  
  181. <TR class="evenRow">
  182.     <TD align=right colspan=2>
  183.         <INPUT type="submit" value="<%=GetText("ChargeUser")%>" name=cmdSave>
  184.     </TD>
  185. </TR>
  186.  
  187. </TABLE>
  188. </FORM>
  189. <%
  190. WriteUserAdminLinks strChargeUser
  191.  
  192. Set objPCWebUsers = Nothing
  193. %>
  194. </CENTER>
  195. <!-- #INCLUDE FILE="includes/footer.inc" -->
  196.